<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>

<html>
	<head>
		<title>公司账户管理</title>
	</head>
	<script type="text/javascript">
		$(function(){
			$("#table").datagrid({
				title:"公司账户管理",
				iconCls:'icon-edit',
				loadMsg:'正在加载数据，请稍后......',
				url:'<%=contextPath %>/springMVC/finance/listPageFinanceCompany',
				rownumbers:true,
				fitColumns:true,
				singleSelect:true,
				nowrap:false,
				idField:'id',
				frozenColumns:[[
				    {title:'主键',field:'id',hidden:true}
				]],
				columns:[[
					{title:'银行',field:'bank',width:200,align:'center'},
					{title:'卡号',field:'account',width:200,align:'center'},
					{title:'开户人',field:'owner',width:100,align:'center'},
					{title:'金额',field:'money',width:100,align:'center'},
					{title:'编辑',field:'edit',fit:true,width:50,align:'center',formatter:function(value,rowDate,rowIndex){
						return "<input type='button'  style='border:0px #ff0000 solid;width:25px;height:15px;cursor:pointer'class='icon-modify'  onClick='addOrEditFinanceCompany(1,\""+rowDate.id+"\")'/>";
					}},
					{title:'往来明细',field:'details',fit:true,width:50,align:'center',formatter:function(value,rowDate,rowIndex){
						return "<input type='button'  style='border:0px #ff0000 solid;width:25px;height:15px;cursor:pointer'class='icon-details'  onClick='showDetails(\""+rowDate.id+"\")'/>";
					}}
				]],
				toolbar:
				[
					{
						id:'add',
						text:'新增',
						iconCls:"icon-add",
						handler:function(){
							addOrEditFinanceCompany(0);
						}
					}
				],
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						$.messager.alert('提示',rtJson.rtMsrg);
					}
				}
			});
		});
		
		function rtCallBack(){
			$('#table').datagrid('reload');
		}
		function addOrEditFinanceCompany(type,id){
			if(type==0){
				openDialogResize("<%=contextPath %>/springViews/finance/addOrEditFinanceCompany.jsp?callback=rtCallBack",1000, 800);
			}else{
				openDialogResize('<%=contextPath %>/springViews/finance/addOrEditFinanceCompany.jsp?callback=rtCallBack&id='+id,1000, 800);
			}
		}
		function showDetails(id){
			openDialogResize('<%=contextPath %>/springViews/finance/financeCompanyLog.jsp?finance_company_id='+id,1000, 800);
		}
	</script>
	<body>
		<div id="table"></div>
	</body>
</html>
